<template>
  <div>
    <div v-loading="floorRoomSign">
      <common v-if="curr == 1" ref="common" :type="type" :financeData="dataList" :peopleId="dataForm.peopleId" :roomId="popInfo.floorRoomId"
        :currState="currState" @setPrintData="setPrintData" @refreYuShouListFinanceBtn="yushouqlistBtnVa" @refreClosing="unRoom"></common>

      <closing v-if="closingVisible" ref="closing" @refreClosing="unRoom"></closing>
      <showrecord v-if="showrecordVisible" ref="showrecord" @refreClosing="unRoom"></showrecord>
      <closingNew v-if="closingNewVisible" ref="closingNew" @refreClosing="unRoom" @printJieZhangClosing="printJieZhang"></closingNew>
      <transferaccounts v-if="transferaccountsVisible" ref="transferaccounts" @refreClosing="unRoom"></transferaccounts>
      <demolition v-if="demolitionVisible" ref="demolition" @refreClosing="unRoom"></demolition>
      <yushouqlist v-if="yushouqlistVisible" ref="yushouqlist" @refreClosing="unRoom"></yushouqlist>
      <returngoods v-if="returngoodsVisible" ref="returngoods" @refreClosing="unRoom"></returngoods>

      <el-divider></el-divider>

      <!-- 账务 -->
      <el-tabs v-model="currState" @tab-click="handleClick" style="position: relative;">
        <el-tab-pane label="全部" name="all"></el-tab-pane>
        <el-tab-pane label="未结账" name="0"></el-tab-pane>
        <el-tab-pane label="已结账" name="1"></el-tab-pane>
        <el-tab-pane label="已转出" name="2"></el-tab-pane>
        <el-tab-pane label="已冲账" name="3"></el-tab-pane>
      </el-tabs>

      <el-row style="margin-bottom: 10px;">
        <el-row>
          <div class="gaojichaxun">
            <el-button @click="piliangtransferaccountsBtn" v-if="curr == 1" :disabled="multipleSelection.length == 0">部分转账</el-button>
            <el-button @click="piLiangClosingBtn" v-if="curr == 1" :disabled="multipleSelection.length == 0">部分结账</el-button>

            <el-button @click="gaojichaxunVisible = !gaojichaxunVisible" :type="gaojichaxunVisible ? 'danger' : ''">高级查询</el-button>
          </div>
        </el-row>
        <el-row v-show="gaojichaxunVisible">
          <el-date-picker @change="getDataList" v-model="dataForm.date" type="daterange" value-format="yyyy-MM-dd"
            range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期">
          </el-date-picker>
        </el-row>
      </el-row>

      <el-table :data="dataList" border v-loading="dataListLoading" style="width: 100%;" @selection-change="handleSelectionChange">

        <el-table-column type="selection" width="55">
        </el-table-column>

        <el-table-column prop="roomSignNum" header-align="center" align="center" label="房号"></el-table-column>
        <el-table-column prop="payPrice" header-align="center" align="center" label="科目/方式">
          <template slot-scope="scope">
            <div v-if="scope.row.payType == 0"><span>预收账款</span></div>
            <div v-if="scope.row.payType == 1"><span>预授权</span></div>
            <div v-if="scope.row.payType == 2||scope.row.payType == 12">
              <span v-if="scope.row.payType == 2">
                <el-button type="primary" plain size="small" @click="shopViewBtn(scope.row.id)">{{ scope.row.consumeName }}</el-button>
              </span>
              <span v-else>{{ scope.row.consumeName }}</span>
            </div>
            <div v-if="scope.row.payType == 3"><span>押金</span></div>
            <div v-if="scope.row.payType == 4">
              <span v-if="scope.row.isNightTrial == 1">夜审房费</span>
              <span v-else>当日房费</span>
            </div>
            <div v-if="scope.row.payType == 5"><span>预收退款</span></div>
            <div v-if="scope.row.payType == 6"><span>结账收款</span></div>
            <div v-if="scope.row.payType == 7"><span>结账退款</span></div>
            <div v-if="scope.row.payType == 8"><span>退押金</span></div>
            <div v-if="scope.row.payType == 9"><span>冲账</span></div>
            <div v-if="scope.row.payType == 10"><span>会员费</span></div>
            <div v-if="scope.row.payType == 13"><span>优惠金额</span></div>
          </template>
        </el-table-column>
        <el-table-column prop="payPrice" header-align="center" align="center" label="付款方式">
          <template slot-scope="scope">
            <span v-if="scope.row.nowTypeName">{{ scope.row.nowTypeName }}</span>
            <span v-else>--</span>
          </template>
        </el-table-column>

        <el-table-column prop="payPrice" header-align="center" align="center" label="消费">
          <template slot-scope="scope">
            <span v-if="scope.row.payType == 2 || scope.row.payType == 4 || scope.row.payType == 9 || scope.row.payType == 12||scope.row.payType == 20|| scope.row.payType == 13|| scope.row.payType == 10"
              style="color: #f24e4c!important">
              ￥
              <span v-if="scope.row.payType == 9 || scope.row.payType == 12|| scope.row.payType == 13">-</span>
              {{ scope.row.payPrice }}</span>
            <span v-else style="color: #f24e4c!important">--</span>
          </template>
        </el-table-column>

        <el-table-column prop="payPrice" header-align="center" align="center" label="收款">
          <template slot-scope="scope">
            <span v-if="scope.row.payType == 0 || scope.row.payType == 3 || scope.row.payType == 6 || scope.row.payType == 5 || scope.row.payType == 7 || scope.row.payType == 8"
              style="color: #31c88b;">
              ￥
              <span v-if="scope.row.payType == 8 || scope.row.payType == 5 || scope.row.payType == 7">-</span>
              {{ scope.row.payPrice }}
            </span>
            <span v-else style="color: #31c88b;">--</span>
          </template>
        </el-table-column>

        <el-table-column prop="remarks" header-align="center" align="center" label="备注">
          <template slot-scope="scope">
            <span v-if="scope.row.remarks">{{ scope.row.remarks }}</span>
            <span v-else>暂无</span>
          </template>
        </el-table-column>

        <el-table-column prop="kedanremake" header-align="center" align="center" label="客单备注">
          <template slot-scope="scope">
            <el-input v-model="scope.row.kedanremake" @change="updateshopByc(scope.row)" placeholder="客单备注"></el-input>
          </template>
        </el-table-column>

        <el-table-column prop="creatTime" header-align="center" align="center" label="时间"></el-table-column>
        <el-table-column prop="businessDay" header-align="center" align="center" label="营业日">
          <template slot-scope="scope">
            <span v-if="scope.row.businessDay">{{scope.row.businessDay}}</span>
            <span v-else>--</span>
          </template>
        </el-table-column>

        <el-table-column prop="type" header-align="center" align="center" label="标签">
          <template slot-scope="scope">
            <span v-if="scope.row.type == 0">未结</span>
            <span v-if="scope.row.type == 1">已结</span>
            <span v-if="scope.row.type == 2">已转</span>
            <span v-if="scope.row.turnType == 1">,转出</span>
            <span v-if="scope.row.turnType == 2">,转入</span>
            <span v-if="scope.row.demolitionType == 1">,拆账</span>
          </template>
        </el-table-column>
        <el-table-column prop="username" header-align="center" align="center" label="操作人"></el-table-column>
        <el-table-column fixed="right" header-align="center" align="center" width="150" label="操作">
          <template slot-scope="scope" v-if="scope.row.payType!=9&&scope.row.payType!=20">
            <el-button type="text" size="small" v-if="scope.row.type == 2" @click="revokeTransferBtn(scope.row)">撤销转账</el-button>
            <el-popover placement="left" width="80" trigger="hover">
              <dl class="dl_drop">
                <dd v-if="scope.row.type == 0" @click="closingBtn(scope.row)">结账</dd>
                <dd v-if="scope.row.type == 0" @click="transferaccountsBtn(scope.row)">转账</dd>
                <dd v-if="scope.row.type == 0" @click="demolitionBtn(scope.row)">拆账</dd>
                <dd v-if="scope.row.payType == 2 && scope.row.type == 0" @click="returnGoods(scope.row.id)">退货</dd>
                <dd v-if="scope.row.payType == 0 || scope.row.payType == 3 || scope.row.payType == 9"
                  @click="printSK(scope.row)">收款单</dd>
                <dd @click="printJieZhang(scope.row.id)" v-if="scope.row.type == 1">结账单</dd>
                <dd @click="cancelCheckoutBtn2([scope.row])" v-if="scope.row.type == 1 && scope.row.isNightTrial == 0">撤销结账</dd>
                <!-- <dd @click="printfkK(scope.row)">付款单</dd> -->
              </dl>
              <el-button type="text" size="small" slot="reference"><i class="el-icon-more" title="更多" id="printMenu"></i></el-button>
            </el-popover>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" :current-page="pageIndex"
        :page-sizes="[10, 20, 50, 100]" :page-size="pageSize" :total="totalPage" layout="total, sizes, prev, pager, next, jumper"></el-pagination>
    </div>

    <!-- <t4 v-show="false" id="t4" :note="this.printconfig2.note" :info="this.info" :priceMap="this.priceMap" :currData="this.currData"
      :finance-data="this.financeData" ref="t4"></t4>
    <t5 v-show="false" id="t5" :note="this.printconfig2.note" :info="this.info" :priceMap="this.priceMap" :currData="this.currData"
      :finance-data="this.financeData" ref="t5"></t5>
    <t6 v-show="false" id="t6" :note="this.printconfig2.note" :info="this.info" :priceMap="this.priceMap" :currData="this.currData"
      :finance-data="this.financeData" ref="t6"></t6>


    <t7 v-show="false" id="t7" :note="this.printconfig.note" :info="this.info" :priceMap="this.priceMap" :currData="this.currData"
      :finance-data="dataList" :row-data="rowData" ref="t7"></t7>
    <t8 v-show="false" id="t8" :note="this.printconfig.note" :info="this.info" :priceMap="this.priceMap" :currData="this.currData"
      :finance-data="this.financeData" :row-data="rowData" ref="t8"></t8>
    <t9 v-show="false" id="t9" :note="this.printconfig.note" :info="this.info" :priceMap="this.priceMap" :currData="this.currData"
      :finance-data="this.financeData" :row-data="rowData" ref="t9"></t9>
    <fk7 v-show="false" id="fk7" :note="this.printconfig.note" :info="this.info" :priceMap="this.priceMap" :currData="this.currData"
      :finance-data="dataList" :row-data="rowData" ref="fk7"></fk7>
    <fk8 v-show="false" id="fk8" :note="this.printconfig.note" :info="this.info" :priceMap="this.priceMap" :currData="this.currData"
      :finance-data="this.financeData" :row-data="rowData" ref="fk8"></fk8>
    <fk9 v-show="false" id="fk9" :note="this.printconfig.note" :info="this.info" :priceMap="this.priceMap" :currData="this.currData"
      :finance-data="this.financeData" :row-data="rowData" ref="fk9"></fk9> -->
  </div>






</template>

<script>
  import moment from 'moment';
  import common from './common';
  import closing from './finance/closing';
  import closingNew from './finance/closing-new.vue';
  import demolition from './finance/demolition';
  import returngoods from './finance/returngoods';
  import showrecord from './finance/showrecord';
  import transferaccounts from './finance/transferaccounts';
  import yushouqlist from './yushouqlist';
  import t7 from '../../../common/printtemplate/shoukuan_58mm';
  import t8 from '../../../common/printtemplate/shoukuan_80mm';
  import t9 from '../../../common/printtemplate/shoukuan_A5';
  import fk7 from '../../../common/printtemplate/fukuan_58mm';
  import fk8 from '../../../common/printtemplate/fukuan_80mm';
  import fk9 from '../../../common/printtemplate/fukuan_A5';
  import t4 from '../../../common/printtemplate/jiezhang_58mm';
  import t5 from '../../../common/printtemplate/jiezhang_80mm';
  import t6 from '../../../common/printtemplate/jiezhang_A5';
  import {
    getLodop
  } from '../../../../utils/lodop';
  export default {
    props: ['type'],
    data() {
      return {
        accSocket: null,
        multipleSelection: [],
        floorRoomSign: false,
        piliangSelectionFlag: false,
        gaojichaxunVisible: false,
        curr: 1,
        currState: '0',
        info: {
          peopleEntity: {},
          singleEntity: {},
          floorRoomEntity: {},
          roomEntity: {}
        },
        clist: [],
        cslist: [],
        popInfo: {},
        dataForm: {
          singleId: '',
          peopleId: '',
          roomIds: '',
          date: []
        },
        formInline: {
          csid: '',
          cid: '',
          pid: ''
        },
        dataList: [],
        pageIndex: 1,
        pageSize: 10,
        totalPage: 0,
        dataListLoading: false,
        closingVisible: false,
        showrecordVisible: false,
        closingNewVisible: false,
        yushouqlistVisible: false,
        returngoodsVisible: false,
        transferaccountsVisible: false,
        demolitionVisible: false,
        timerInOut: '',
        printconfig: {}, //打印配置
        currData: '',
        priceMap: {},
        record: [],
        rowData: {}
      };
    },
    components: {
      common,
      closing,
      closingNew,
      transferaccounts,
      yushouqlist,
      demolition,
      returngoods,
      showrecord,
      t7,
      t8,
      t9,
      t4,
      t5,
      t6,
      fk7,
      fk8,
      fk9
    },
    methods: {
      handleSelectionChange(val) {
        console.log(val)
        this.multipleSelection = val;
      },
      returnGoods(id) {
        this.returngoodsVisible = true;
        this.$nextTick(() => {
          this.$refs.returngoods.init(id);
        });
      },
      shopViewBtn(id) {
        this.showrecordVisible = true;
        this.$nextTick(() => {
          this.$refs.showrecord.init(id);
        });
      },
      transferaccountssBtn(row) {
        row["consumeName"] = row.cname;
        this.transferaccountsBtn(row);
      },
      closingsBtn(row) {

        row["consumeName"] = row.cname;
        this.closingBtn(row);
      },
      print(printFlag) {
        if (printFlag == 1) {
          console.log("自动打印：finance" + printFlag)
          this.$nextTick(() => {
            this.$refs.common.print(printFlag);
          });
        }
      },
      demolitionBtn(item) {
        this.demolitionVisible = true;
        this.$nextTick(() => {
          this.$refs.demolition.init(item, item.peopleId);
        });
      },
      yushouqlistBtnVa() {
        console.log(1);
        this.yushouqlistVisible = true;
        this.$nextTick(() => {
          if (this.curr == 1) {
            this.$refs.yushouqlist.init(this.popInfo);
          } else if (this.curr == 2) {
            this.$refs.yushouqlist.init2(this.info);
          }
        });
      },
      closingBtn(item) {
        this.closingNewVisible = true;
        this.$nextTick(() => {
          this.$refs.closingNew.init([item], item.peopleId, this.popInfo.singleId);
        });
      },
      piLiangClosingBtn() {
        if (this.multipleSelection.length == 0) {
          this.$message.error("请选择数据");
          return false
        }
        var list = []
        this.multipleSelection.forEach(item => {
          if (item.type == 0) {
            list.push(item)
          }
        })
        this.closingNewVisible = true;
        this.$nextTick(() => {
          this.$refs.closingNew.init(list, this.popInfo.id, this.popInfo.singleId);
        });
      },
      cancelCheckoutBtn(){
        if (this.multipleSelection.length == 0) {
          this.$message.error("请选择数据");
          return false
        }
        var ids = []
        this.multipleSelection.forEach(item => {
          if (item.type == 1 && item.isNightTrial == 0) {
            ids.push(item.id)
          }
        })
        console.log("this.multipleSelection",this.multipleSelection)
        console.log("ids",ids)
        this.$confirm('撤销结账, 是否继续?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning',
            beforeClose: (action, instance, done) => {
              if (action === 'confirm') {
                instance.confirmButtonLoading = true;
                instance.confirmButtonText = '执行中...';
                this.$http({
                  url: this.$http.adornUrl(`/hotel/thotelfloorroomcheckinaccounting/cancelCheckout`),
                  method: 'get',
                  params: this.$http.adornParams({
                    submitIds: ids.join(",")
                  })
                }).then(({
                  data
                }) => {
                  setTimeout(() => {
                    instance.confirmButtonLoading = false;
                  }, 300);
                  instance.confirmButtonText = '确定';
                  if (data && data.code === 0) {
                    done();
                  } else {
                    this.$message.error(data.msg);
                  }
                });
              } else {
                done();
              }
            }
          })
          .then(() => {
            this.$message({
              message: this.$t('Common.OperationSuccessful'),
              type: 'success',
              duration: 1500,
              onClose: () => {
                this.unRoom();
              }
            });
          })
          .catch(() => {
            this.$message({
              type: 'info',
              message: '已取消操作'
            });
          });
      },
      cancelCheckoutBtn2(multipleSelection){
        if (multipleSelection.length == 0) {
          this.$message.error("请选择数据");
          return false
        }
        var ids = []
        multipleSelection.forEach(item => {
          if (item.type == 1 && item.isNightTrial == 0) {
            ids.push(item.id)
          }
        })
        console.log("multipleSelection",multipleSelection)
        console.log("ids",ids)
        this.$confirm('撤销结账, 是否继续?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning',
            beforeClose: (action, instance, done) => {
              if (action === 'confirm') {
                instance.confirmButtonLoading = true;
                instance.confirmButtonText = '执行中...';
                this.$http({
                  url: this.$http.adornUrl(`/hotel/thotelfloorroomcheckinaccounting/cancelCheckout`),
                  method: 'get',
                  params: this.$http.adornParams({
                    submitIds: ids.join(",")
                  })
                }).then(({
                  data
                }) => {
                  setTimeout(() => {
                    instance.confirmButtonLoading = false;
                  }, 300);
                  instance.confirmButtonText = '确定';
                  if (data && data.code === 0) {
                    done();
                    this.unRoom();
                  } else {
                    this.$message.error(data.msg);
                  }
                });
              } else {
                done();
              }
            }
          })
          .then(() => {
            this.$message({
              message: this.$t('Common.OperationSuccessful'),
              type: 'success',
              duration: 1500,
              onClose: () => {

              }
            });
          })
          .catch(() => {
            this.$message({
              type: 'info',
              message: '已取消操作'
            });
          });
      },
      printJieZhang(id){
        this.$http({
          url: this.$http.adornUrl(`/hotel/thotelfloorroomcheckinaccounting/printJieZhang`),
          method: 'post',
          params: this.$http.adornParams({
            id: id
          })
        }).then(({
          data
        }) => {
          if (data && data.code === 0) {
            console.log(data.data)
            this.$refs.t4.initFinanceData(data.data);
            this.$refs.t5.initFinanceData(data.data);
            this.$refs.t6.initFinanceData(data.data);
            this.$refs.t4.initMemberLevelDetailEntity(data.memberLevelDetailEntity);
            this.$refs.t5.initMemberLevelDetailEntity(data.memberLevelDetailEntity);
            this.$refs.t6.initMemberLevelDetailEntity(data.memberLevelDetailEntity);
            this.$nextTick(() => {
              const _that = this
              setTimeout(() => {
                _that.printPreview2();
              }, 500);
            });
          } else {
            this.$message.error(data.msg);
          }
        });
      },
      getPrintMsg() {
        this.$http({
          url: this.$http.adornUrl(`/hotel/thotelprinttemplate/info/2`),
          method: 'get'
        }).then(({
          data
        }) => {
          if (data && data.code === 0) {
            this.printconfig2 = data.tHotelPrintTemplate;
          }
        });
      },
      printPreview2() {
        console.log("printPreview2",this.$refs.t5.$refs.t5.innerHTML)

        LODOP = getLodop();
        if (!LODOP) {
          this.$alert(
            `<br><font color='#FF00FF'>CLodop云打印服务(localhost本地)未安装启动!点击这里<a href='http://www.lodop.net/download/CLodop_Setup_for_Win32NT_4.088Extend.zip' download target='_self'>执行安装</a>,安装后请刷新页面。</font>`,
            '安装', {
              confirmButtonText: '确定',
              dangerouslyUseHTMLString: true
            }
          );
          return;
        }

        //样式
        var strStyleCSS = " <link href='https://ebooking.qlan99.com/css/print.css' type='text/css' rel='stylesheet'> ";

        var olstyle1 = '<!DOCTYPE html><html lang="zh-CN"><head>' + strStyleCSS + '</head>' + ' <style> ' +
          'div{border:0!important}' + '</style>';
        var body = '';
        if (this.printconfig2.specs === '58mm') {
          var olstyle2 = '<style> .print-wrap-normal{width:' + (58 + parseInt(this.printconfig2.printContentOffset)) +
            'mm !important}</style>';
          body = olstyle1 + olstyle2 + '<body>' + this.$refs.t4.$refs.t4.innerHTML + '</body>';
          LODOP.SET_PRINT_PAGESIZE(0, 580, 2000, ''); //设定纸张大小
        }
        if (this.printconfig2.specs === '80mm') {
          var olstyle2 = '<style> .print-wrap-normal{width:' + (80 + parseInt(this.printconfig2.printContentOffset)) +
            'mm !important}</style>';
          body = olstyle1 + olstyle2 + '<body>' + this.$refs.t5.$refs.t5.innerHTML + '</body>';
          LODOP.SET_PRINT_PAGESIZE(0, 800, 2000, ''); //设定纸张大小
        }
        if (this.printconfig2.specs === 'A5') {
          var olstyle2 = '<style> .print-wrap-normal{width:' + (210 + parseInt(this.printconfig2.printContentOffset)) +
            'mm !important}</style>';
          body = olstyle1 + olstyle2 + '<body>' + this.$refs.t6.$refs.t6.innerHTML + '</body>';
          LODOP.SET_PRINT_PAGESIZE(0, 2100, 2000, ''); //设定纸张大小
        }
        body += '</html>';

        LODOP.ADD_PRINT_HTM(0, this.printconfig2.printPaperOffset, 1000, 2000, body); //增加超文本项

        LODOP.SET_PRINT_MODE('PRINT_PAGE_PERCENT', '100%'); //设置缩放
        // LODOP.PRINT_INIT('订单') //打印初始化
        LODOP.SET_PRINT_STYLE('FontSize', 12); //设置对象风格
        LODOP.SET_PRINT_STYLE('Bold', 1); ////设置对象风格
        LODOP.SET_PREVIEW_WINDOW(0, 0, 0, 0, 0, ''); //设置窗口
        LODOP.SET_PRINT_COPIES(this.printconfig2.printSum);

        LODOP.SET_LICENSES("", "4B44F795076C8F14211A5ED0A5339305DAB", "23580B189D96F33252722697A57AC00506B",
          "");

        if (this.printconfig2.preview) {
          console.log("this.printconfig.defaultPrint",this.printconfig2.defaultPrint)
          console.log("LODOP.SET_PRINTER_INDEXA(this.printconfig.defaultPrint)",LODOP.SET_PRINTER_INDEXA(this.printconfig2.defaultPrint))
          if (LODOP.SET_PRINTER_INDEXA(this.printconfig2.defaultPrint)) {
            LODOP.SET_PRINTER_INDEXA(this.printconfig2.defaultPrint);
            LODOP.PRINT();
            // LODOP.PRINT_DESIGN();
          } else {
            LODOP.SET_PRINTER_INDEXA(0);
            LODOP.PRINT();
            // LODOP.PRINT_DESIGN();
          }
        } else {
          if (LODOP.SET_PRINTER_INDEXA(this.printconfig2.defaultPrint)) {
            LODOP.SET_PRINTER_INDEXA(this.printconfig2.defaultPrint);
            LODOP.PREVIEW();
          } else {
            LODOP.SET_PRINTER_INDEXA(0);
            LODOP.PREVIEW();
            // LODOP.PRINT_DESIGN();
          }
        }
      },
      /*
      撤销转账
      */
      revokeTransferBtn(item) {
        this.$confirm('撤销转账, 是否继续?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning',
            beforeClose: (action, instance, done) => {
              if (action === 'confirm') {
                instance.confirmButtonLoading = true;
                instance.confirmButtonText = '执行中...';
                this.$http({
                  url: this.$http.adornUrl(`/hotel/thotelfloorroomcheckinaccounting/revokeTransfer`),
                  method: 'post',
                  data: this.$http.adornData({
                    submitIds: item.id
                  })
                }).then(({
                  data
                }) => {
                  setTimeout(() => {
                    instance.confirmButtonLoading = false;
                  }, 300);
                  instance.confirmButtonText = '确定';
                  if (data && data.code === 0) {
                    done();
                  } else {
                    this.$message.error(data.msg);
                  }
                });
              } else {
                done();
              }
            }
          })
          .then(() => {
            this.$message({
              message: this.$t('Common.OperationSuccessful'),
              type: 'success',
              duration: 1500,
              onClose: () => {
                this.unRoom();
              }
            });
          })
          .catch(() => {
            this.$message({
              type: 'info',
              message: '已取消操作'
            });
          });
      },
      getclist(id) {
        this.$http({
          url: this.$http.adornUrl(`/hotel/thotelfloorroomconsume/getclist`),
          method: 'get',
          params: this.$http.adornParams({
            id: id
          })
        }).then(({
          data
        }) => {
          this.clist = data.page;
        });
      },
      getcslist() {
        this.$http({
          url: this.$http.adornUrl(`/hotel/thotelfloorroomconsume/getcslist`),
          method: 'get',
        }).then(({
          data
        }) => {
          this.cslist = data.page;
        });
      },
      xiangxilog() {
        this.getcslist();
        this.formInline.pid = this.dataForm.peopleId;
        this.formInline.type = this.currState;
        this.$http({
          url: this.$http.adornUrl(`/hotel/thotelfloorroomshoprecord/getrecordByid`),
          method: 'get',
          params: this.formInline
        }).then(({
          data
        }) => {
          this.record = data.page;
          // this.showrecord=true;
        });
      },
      transferaccountsBtn(item) {
        this.transferaccountsVisible = true;
        this.$nextTick(() => {
          this.$refs.transferaccounts.init([item], item.peopleId);
        });
      },
      piliangtransferaccountsBtn() {
        if (this.multipleSelection.length == 0) {
          this.$message.error("请选择数据");
          return false
        }
        var list = []
        this.multipleSelection.forEach(item => {
          if (item.type == 0) {
            list.push(item)
          }
        })
        this.transferaccountsVisible = true;
        this.$nextTick(() => {
          this.$refs.transferaccounts.init(list, this.popInfo.id);
        });
      },
      unRoom() {
        this.$emit('refreClosing');
        if (this.curr == 1) {
          this.getDataList();
        } else {
          this.getDataList2();
        }
      },
      init(pop) {

        this.getPrintMsg();
        this.curr = 1;
        this.popInfo = pop;
        this.dataForm.peopleId = pop.id;
        this.$refs.common.init(pop);
        this.getDataList();
        this.$nextTick(() => {});
      },
      init2(info) {

        this.getPrintMsg();
        this.info = info;
        this.curr = 2;
        console.log(info);
        this.dataForm.roomIds = info.roomIds;
        this.dataForm.singleId = info.singleId;
        this.getDataList2();
        this.$nextTick(() => {
          // this.$refs.common.init(pop);
        });
      },
      handleClick(tab, res) {
        console.log("currState", this.currState);
        if (this.currState == 3) {
          this.getCzList();
          return true
        }

        if (this.curr == 1) {
          this.getDataList();
        } else {
          this.getDataList2();
        }
      },
      getAccountingList() {},
      // 获取数据列表
      getDataList() {
        var startdate = '';
        var enddate = '';
        if (this.dataForm.date != null && this.dataForm.date.length != 0) {
          startdate = this.dataForm.date[0];
          enddate = this.dataForm.date[1];
        }
        this.dataListLoading = true;
        this.$http({
          url: this.$http.adornUrl('/hotel/thotelfloorroomcheckinaccounting/list'),
          method: 'get',
          params: this.$http.adornParams({
            page: this.pageIndex,
            limit: this.pageSize,
            peopleId: this.dataForm.peopleId,
            fid: this.dataForm.foomFloorId,
            viewType: 1,
            startdate: startdate,
            enddate: enddate,
            type: this.currState
          })
        }).then(({
          data
        }) => {
          if (data && data.code === 0) {
            this.dataList = data.page.list;
            this.totalPage = data.page.totalCount;
          } else {
            this.dataList = [];
            this.totalPage = 0;
          }
          this.dataListLoading = false;
        });
      },
      // 获取数据列表
      getDataList2() {
        this.dataListLoading = true;
        this.$http({
          url: this.$http.adornUrl('/hotel/thotelfloorroomcheckinaccounting/list2'),
          method: 'get',
          params: this.$http.adornParams({
            page: this.pageIndex,
            limit: this.pageSize,
            roomIds: this.dataForm.roomIds,
            type: this.currState,
            singleId: this.dataForm.singleId
          })
        }).then(({
          data
        }) => {
          if (data && data.code === 0) {
            this.dataList = data.page.list;
            this.totalPage = data.page.totalCount;
          } else {
            this.dataList = [];
            this.totalPage = 0;
          }
          this.dataListLoading = false;
        });
      },
      getCzList() {
        this.dataListLoading = true;
        this.$http({
          url: this.$http.adornUrl('/hotel/thotelfloorroomcheckinaccounting/getByPayTypeWithCZList'),
          method: 'get',
          params: this.$http.adornParams({
            page: this.pageIndex,
            limit: this.pageSize,
            payType: 9,
            peopleId: this.info.peopleEntity.id
          })
        }).then(({
          data
        }) => {
          if (data && data.code === 0) {
            this.dataList = data.page.list;
            this.totalPage = data.page.totalCount;
            console.log("czdata:", data)
          } else {
            this.dataList = [];
            this.totalPage = 0;
          }
          this.dataListLoading = false;
        });
      },
      // 每页数
      sizeChangeHandle(val) {
        this.pageSize = val;
        this.pageIndex = 1;

        if (this.currState == 3) {
          this.getCzList();
          return true
        }
        if (this.curr == 1) {
          this.getDataList();
        } else {
          this.getDataList2();
        }
      },
      // 当前页
      currentChangeHandle(val) {
        this.pageIndex = val;

        if (this.currState == 3) {
          this.getCzList();
          return true
        }
        if (this.curr == 1) {
          this.getDataList();
        } else {
          this.getDataList2();
        }
      },
      // 多选
      selectionChangeHandle(val) {
        this.dataListSelections = val;
      },
      // 删除
      deleteHandle(id) {
        var ids = id ?
          [id] :
          this.dataListSelections.map(item => {
            return item.id;
          });
        this.$confirm(`确定对[id=${ids.join(',')}]进行[${id ? '删除' : '批量删除'}]操作?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$http({
            url: this.$http.adornUrl('/hotel/thotelfloorroomcheckinaccounting/delete'),
            method: 'post',
            data: this.$http.adornData(ids, false)
          }).then(({
            data
          }) => {
            if (data && data.code === 0) {
              this.$message({
                message: this.$t('Common.OperationSuccessful'),
                type: 'success',
                duration: 1500,
                onClose: () => {
                  if (this.curr == 1) {
                    this.getDataList();
                  } else {
                    this.getDataList2();
                  }
                }
              });
            } else {
              this.$message.error(data.msg);
            }
          });
        });
      },
      setPrintData(info, currData, priceMap) {
        // :note='this.printconfig.note'
        // :info='this.info'
        // :priceMap='this.priceMap'
        // :currData='this.currData'
        this.info = info;
        this.currData = currData;
        this.priceMap = priceMap;
      },
      loadPrintConfig() {
        this.$http({
          url: this.$http.adornUrl(`/hotel/thotelprinttemplate/info/3`),
          method: 'get'
        }).then(({
          data
        }) => {
          if (data && data.code === 0) {
            this.printconfig = data.tHotelPrintTemplate;
          } else {
            this.$message.error(data.msg);
          }
        });
      },
      printSK(rowData) {
        this.$refs.t7.setRowData(rowData);
        this.$refs.t8.setRowData(rowData);
        this.$refs.t9.setRowData(rowData);
        this.$nextTick(() => {
          this.rowData = rowData;
          LODOP = getLodop();
          if (!LODOP) {
            this.$alert(
              `<br><font color='#FF00FF'>CLodop云打印服务(localhost本地)未安装启动!点击这里<a href='http://www.lodop.net/download/CLodop_Setup_for_Win32NT_4.088Extend.zip' download target='_self'>执行安装</a>,安装后请刷新页面。</font>`,
              '安装', {
                confirmButtonText: '确定',
                dangerouslyUseHTMLString: true
              }
            );
            return;
          }
          //样式
          var strStyleCSS =
            " <link href='https://ebooking.qlan99.com/css/print.css' type='text/css' rel='stylesheet'> ";

          var olstyle1 = '<!DOCTYPE html><html lang="zh-CN"><head>' + strStyleCSS + '</head>' + ' <style> ' +
            'div{border:0!important}' + '</style>';
          var body = '';
          if (this.printconfig.specs === '58mm') {
            body = olstyle1 + '<body>' + this.$refs.t7.$refs.t7.innerHTML + '</body>';
            LODOP.SET_PRINT_PAGESIZE(0, 580, 3000, ''); //设定纸张大小
          }
          if (this.printconfig.specs === '80mm') {
            body = olstyle1 + '<body>' + this.$refs.t8.$refs.t8.innerHTML + '</body>';
            LODOP.SET_PRINT_PAGESIZE(0, 800, 2500, ''); //设定纸张大小
          }
          if (this.printconfig.specs === 'A5') {
            body = olstyle1 + '<body>' + this.$refs.t9.$refs.t9.innerHTML + '</body>';
            LODOP.SET_PRINT_PAGESIZE(0, 2100, 2000, ''); //设定纸张大小
          }
          body += '</html>';
          LODOP.ADD_PRINT_HTM(0, 0, 1000, 2000, body); //增加超文本项

          LODOP.SET_PRINT_MODE('PRINT_PAGE_PERCENT', '100%'); //设置缩放
          // LODOP.PRINT_INIT('订单') //打印初始化
          LODOP.SET_PRINT_STYLE('FontSize', 12); //设置对象风格
          LODOP.SET_PRINT_STYLE('Bold', 1); ////设置对象风格
          LODOP.SET_PREVIEW_WINDOW(0, 0, 0, 0, 0, ''); //设置窗口
          LODOP.SET_PRINT_COPIES(this.printconfig.printSum);
          if (this.printconfig.preview) {
            if (LODOP.SET_PRINTER_INDEXA(this.printconfig.defaultPrint))
              // LODOP.PRINT_DESIGN();
              LODOP.PRINT();
            else {
              LODOP.SET_PRINTER_INDEXA(0);
              // LODOP.PRINT_DESIGN();
              LODOP.PRINT();
            }
          } else {
            if (LODOP.SET_PRINTER_INDEXA(this.printconfig.defaultPrint))
              // LODOP.PRINT_DESIGN();
              LODOP.PREVIEW();
            else {
              LODOP.SET_PRINTER_INDEXA(0);
              // LODOP.PRINT_DESIGN();
              LODOP.PREVIEW();
            }
          }
        });
      },
      updateshopByc(row) {
        this.$http({
          url: this.$http.adornUrl(
            `/hotel/thotelfloorroomshoprecord/updateBycid`
          ),
          method: "post",
          data: {
            id: row.id,
            kedanremake: row.kedanremake,
          }
        }).then(({
          data
        }) => {
          if (data && data.code === 0) {
            this.$message({
              message: "操作成功",
              type: "success",
              duration: 1500,
              onClose: () => {
                this.getDataList();
              }
            });
          } else {
            this.$message.error(data.msg);
          }
        });
      },
      updateByc(row) {
        this.$http({
          url: this.$http.adornUrl(
            `/hotel/thotelfloorroomcheckinaccounting/update`
          ),
          method: "post",
          data: row
        }).then(({
          data
        }) => {
          if (data && data.code === 0) {
            this.$message({
              message: "操作成功",
              type: "success",
              duration: 1500,
              onClose: () => {
                this.getDataList();
              }
            });
          } else {
            this.$message.error(data.msg);
          }
        });

      },
      printfkK(rowData) {
        this.$refs.fk7.setRowData(rowData);
        this.$refs.fk8.setRowData(rowData);
        this.$refs.fk9.setRowData(rowData);
        this.$nextTick(() => {
          this.rowData = rowData;
          LODOP = getLodop();
          if (!LODOP) {
            this.$alert(
              `<br><font color='#FF00FF'>CLodop云打印服务(localhost本地)未安装启动!点击这里<a href='http://www.lodop.net/download/CLodop_Setup_for_Win32NT_4.088Extend.zip' download target='_self'>执行安装</a>,安装后请刷新页面。</font>`,
              '安装', {
                confirmButtonText: '确定',
                dangerouslyUseHTMLString: true
              }
            );
            return;
          }
          //样式
          var strStyleCSS =
            " <link href='https://ebooking.qlan99.com/css/print.css' type='text/css' rel='stylesheet'> ";

          var olstyle1 = '<!DOCTYPE html><html lang="zh-CN"><head>' + strStyleCSS + '</head>' + ' <style> ' +
            'div{border:0!important}' + '</style>';
          var body = '';
          if (this.printconfig.specs === '58mm') {
            body = olstyle1 + '<body>' + this.$refs.fk7.$refs.t7.innerHTML + '</body>';
            LODOP.SET_PRINT_PAGESIZE(0, 580, 3000, ''); //设定纸张大小
          }
          if (this.printconfig.specs === '80mm') {
            body = olstyle1 + '<body>' + this.$refs.fk8.$refs.t8.innerHTML + '</body>';
            LODOP.SET_PRINT_PAGESIZE(0, 800, 2500, ''); //设定纸张大小
          }
          if (this.printconfig.specs === 'A5') {
            body = olstyle1 + '<body>' + this.$refs.fk9.$refs.t9.innerHTML + '</body>';
            LODOP.SET_PRINT_PAGESIZE(0, 2100, 2000, ''); //设定纸张大小
          }
          body += '</html>';
          LODOP.ADD_PRINT_HTM(0, 0, 1000, 2000, body); //增加超文本项

          LODOP.SET_PRINT_MODE('PRINT_PAGE_PERCENT', '100%'); //设置缩放
          // LODOP.PRINT_INIT('订单') //打印初始化
          LODOP.SET_PRINT_STYLE('FontSize', 12); //设置对象风格
          LODOP.SET_PRINT_STYLE('Bold', 1); ////设置对象风格
          LODOP.SET_PREVIEW_WINDOW(0, 0, 0, 0, 0, ''); //设置窗口
          LODOP.SET_PRINT_COPIES(this.printconfig.printSum);
          if (this.printconfig.preview) {
            if (LODOP.SET_PRINTER_INDEXA(this.printconfig.defaultPrint)) LODOP.PRINT_DESIGN();
            else {
              LODOP.SET_PRINTER_INDEXA(0);
              LODOP.PRINT_DESIGN();
            }
          } else {
            if (LODOP.SET_PRINTER_INDEXA(this.printconfig.defaultPrint)) LODOP.PRINT_DESIGN();
            else {
              LODOP.SET_PRINTER_INDEXA(0);
              LODOP.PRINT_DESIGN();
            }
          }
        });
      }
    },
    mounted() {
      this.loadPrintConfig();
    }
  };
</script>

<style lang="scss" scoped>
  .common_prompt {
    padding: 9px 16px;
    background: #fff3f2;
    border: 1px solid #fde0d4;
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
  }

  #printMenu {
    transform: rotate(90deg);
  }

  .dl_drop {
    color: rgba(0, 0, 0, 0.65);
    z-index: 999;
    border-radius: 4px;
    overflow: hidden;
  }

  .dl_drop dd {
    padding: 0 15px;
    font-size: 13px;
    height: 35px;
    line-height: 35px;
    cursor: pointer;
    white-space: nowrap;
    margin: 0px;
  }

  .gaojichaxun {
    position: absolute;
    right: 30px;
    top: -54px;

  }

  .el-date-editor /deep/ .el-range-separator {
    width: 7%;
  }
</style>
